
    import java.util.*;
// 1:无需package
// 2: 类名必须Main, 不可修改

    public class Test3 {
        public static void main(String[] args) {
            Scanner scan = new Scanner(System.in);
            //在此输入您的代码...
            int l = scan.nextInt();
            int m = 0,n = 0;
            ArrayList<Integer> list = new ArrayList<>();
            while(scan.hasNext()){
                list.add(scan.nextInt());
            }
            Collections.sort(list);
            for(int i = 1;i < list.size();i++){
                if((list.get(i) - list.get(i - 1)) == 2){
                    m = list.get(i) - 1;
                }else if(list.get(i).equals(list.get(i - 1))){
                    n = list.get(i);
                }
            }
            System.out.println(m + " " + n);
            scan.close();
        }
    }

